(function ($, doc) {
	var state = app.getState();
	var uid = state.user_id;

	$.init();
	window.onload = function () {
		var pgsize = 30;
		var minid = 999999999;
		var getUrl = apiurl + "wallet/getTradesList/?user_id=" + uid + "&minid=" + minid + "&pgsize=" + pgsize;
		$.getJSON(getUrl, function (res) {
			if (res.count > 0) {
				var add = template('list-template', {
					"tradelist": res.data
				});

				//				localStorage.setItem('$tradelist', JSON.stringify(res.data));

				doc.getElementById("mintradeid").value = res.minid;
				doc.getElementById("mytradelist").innerHTML = add;

				/*				if (res.count < pgsize) {
									that.endPullupToRefresh(true);
								} else {
									that.endPullupToRefresh(false);
								}*/
			} else {
				doc.querySelector(".mui-indexed-list-empty-alert").style.display = 'block';
				//				that.endPullupToRefresh(true);
			}
		});
	}

	$("#mytradelist").on("tap", "a", function () {
		var targets = this.getAttribute("href") + "?" + this.getAttribute("value");
		mui.openWindow({
			url: targets,
			id: targets
		});
	});

	/*	window.addEventListener('refresh', function (e) { //执行刷新
			location.reload();
		});*/
}(mui, document));